<template>
  <div>
    <Chart :cdata="cdata" />
  </div>
</template>

<script>
import Chart from './chart.vue'
import request from "../../../../utils/request";
export default {
  data () {
    return {
      cdata: {}
    }
  },
  components: {
    Chart,
  },
  // mounted () {
  //   this.setData()
  // },
  created() {
    this.setData()
  },

  methods: {
    setData () {
      // request.get("https://voice.baidu.com/newpneumonia/getv2?from=mola-virus&stage=publish&target=trend&isCaseIn=1&area=%E7%A6%8F%E5%BB%BA").then(res=>{
      //   // console.log('seri res data=>',res)
      //   // this.cdata = res.result
      //   if (res.status == 0){
      //     console.log("福建累计趋势数据",res.data[0])
      //   }
      // })

      let that = this
      this.ws = this.$store.state.websocketModule.ws
      this.ws.subscribe('/bigScreen/citiesTrend', function (message){//有教程说topic前面必须带一个/user前缀，但是我没加也没事啊在·
        if(message.body != JSON.stringify(that.cdata)){
          console.log("trend=>",JSON.parse(message.body))
          that.cdata = JSON.parse(message.body)
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
</style>